package com.king.java.tools.email;



import com.king.java.tools.email.entity.EmailEntity;
import com.king.java.tools.email.impl.GeneralEmailConfig;
import com.king.java.tools.email.impl.GeneralEmailUtils;

import javax.mail.MessagingException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;

/**
 * 描述:
 *
 * @author : sujinchen
 * @date : 2020/10/13
 */
class EmailUtilsTest {
    public static void main(String[] args) {
        GeneralEmailConfig config = new GeneralEmailConfig("sujinchen@cvte.com","Sp6ATXVrN5aazazu");
        config.setSSL(true);
        config.setDebug(true);
        /**
         * 收件人地址
         */
//         String[] recipientAddress={"sujinchen@cvte.com","dengqisen@cvte.com","zhangqi6278@cvte.com","shijie4274@cvte.com"};
         List<String> recipientAddress=new ArrayList<>();
        recipientAddress.add("xiesongde@cvte.com");

        /**
         * 抄送人地址
         */
        List<String> copyAddress=new ArrayList<>();
        copyAddress.add("sujinchen@cvte.com");
        /**
         * 密送人地址
         */
        List<String> secretAddress=new ArrayList<>();
        secretAddress.add("xiesongde@cvte.com");
//        secretAddress.add("352333178@qq.com");
//        secretAddress.add("1822754074@qq.com");
        /**
         * 邮件主题
         */
         String title="测试邮件";
        /**
         * 邮件正文
         */
        String context="德哥，快把脚本发我。<br/>";
        EmailEntity entity = new EmailEntity("xiesongde@cvte.com","一封测试邮件");
        entity.addPicture("E:\\gitee\\mywork\\work\\rt_parnet\\rt_common\\src\\main\\resources\\cvte.png");
//        entity.addTextContent("回家！");
//        entity.addPicture("E:\\gitee\\mywork\\work\\rt_parnet\\rt_common\\src\\main\\resources\\cvte.png");
        entity.addTextContent("德哥，快把脚本发我。<br/>下班前就要");

//        entity.addTextContent("休息");
//
//        entity.addTextContent("困困");
        entity.addTextContent("<br/>速度哟！" +
                "<hr>" +
                "<b style=\"font-size: 16px;\">苏金陈 |机器人事业部</b><br  /></p><p class=\"MsoNormal\" style=\"margin: 0px 0cm; font-family: 宋体; font-size: 12pt; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;\"><span style=\"font-size: 9pt; font-family: 微软雅黑, sans-serif; color: rgb(50, 51, 51); background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;\">广州视源电子科技股份有限公司<span lang=\"EN-US\">&nbsp;| </span>客服热线：<span lang=\"EN-US\">400-880-7168 | <a href=\"http://www.cvte.com/\" style=\"color: blue; text-decoration: none !important;\"><span style=\"color: rgb(5, 99, 193);\">www.cvte.com</span></a><br  /></span>手<span lang=\"EN-US\">&nbsp; </span>机：<span lang=\"EN-US\">(+86) 13921813029</span></span></p><p class=\"MsoNormal\" style=\"margin: 0px 0cm; font-family: 宋体; font-size: 12pt; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;\"><span lang=\"EN-US\" style=\"font-size: 9pt; font-family: 微软雅黑, sans-serif; color: rgb(50, 51, 51); background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;\">CVTE</span><span style=\"font-size: 9pt; font-family: 微软雅黑, sans-serif; color: rgb(50, 51, 51); background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;\">第二产业园：广州市黄埔区云埔四路<span lang=\"EN-US\">6</span>号</span><span style=\"font-size: 9pt; font-family: 微软雅黑, sans-serif; color: rgb(50, 51, 51);\">（<span lang=\"EN-US\">510530</span>）</span></p><p class=\"MsoNormal\" align=\"left\" style=\"\">&nbsp;" +
                "<img src='cid:image1'/>" +
                "<br  />“This email and all attachments are trade secrets of Guangzhou Shiyuan Electronics&nbsp; Co., Ltd. and its affilates , and may be used only by the recipient/s for purposes designated by our company. Without our consent, no one may reveal, describe or forward this email to others or use it for any other purposes.<span style=\"font-size: 10.5pt; line-height: 1.5; background-color: transparent;\">Ifyoureceivedthisemail in error, please notify the sender immediately, irretrievably delete this email and all attachments from your system and any other medium or carrier, and do not keep this email in electronic, printed or any other form.</span></p><p class=\"MsoNormal\" align=\"left\" style=\"\">----------------------------------------------------------------------------------------------------------------------------------------------------<br  />本邮件及附件均系广州视源电子科技股份有限公司及关联公司之商业秘密，仅供收到邮件者用于我司指定之用途，未经允许，不得向他人显示、转述或转发，也不得用于任何其他目的。若您误收本邮件，请即刻通知发件人，并立即将本邮件及其附件从系统及其它任何载体、介质中彻底删除，切勿以电子、打印或任何其他方式保留。</p>"
        );
        entity.addPicture("E:\\gitee\\mywork\\work\\rt_parnet\\rt_common\\src\\main\\resources\\cvte.png");

        entity.addAccessory("E:\\gitee\\mywork\\work\\rt_parnet\\rt_common\\src\\main\\resources\\2020年10月份整机测试问题反馈.xlsx");

        EmailUtil utils = new GeneralEmailUtils(config, entity);
        try {
            String send = utils.send();
            System.out.println(send);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (MessagingException e) {
            e.printStackTrace();
        }

    }

}